package pl.druminski.robinhood.controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.Proxy;
import pl.druminski.robinhood.model.Data;
import pl.druminski.robinhood.view.DialogAddProxy;
import pl.druminski.robinhood.view.Gui;

/**
 * @author Łukasz Drumiński
 * 
 */
public class ALAddProxy implements ActionListener
{
    Data data;
    Gui gui;

    public ALAddProxy(Data data, Gui gui)
    {
        this.data = data;
        this.gui = gui;
    }

    public void actionPerformed(ActionEvent e)
    {
        DialogAddProxy dialog = new DialogAddProxy(gui);
        dialog.setVisible(true);

        Proxy proxy = dialog.getProxy();

        if(proxy != null)
        {
            data.proxyList.add(proxy);
            gui.proxyModel.fireTableRowsInserted(0, data.proxyList.size());
        }
    }

}
